﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hi_Baidu.Packet.InPacket;

namespace Hi_Baidu.ProcessModel
{
    class FriendViewModel
    {
        private delegate void PUBLIC_STRING_DELEGATE(String Text);

        /// <summary>
        ///     当申请的好友不存在时候的处理
        /// </summary>
        /// <param name="inpackage"></param>
        public static void View_GetPostFriendInfo_NotFind(GetPostFriendInfoNotFind_ReplyPacket inpackage)
        {
            //提示错误
            ShowNotifyWindow("要加的好友不存在 !");
            //清除添加好友号码框
            IMetaData win_PostAddFriend = Globle.popWindowManager.GetMemberByKey("PostAddFriend");
            if (win_PostAddFriend != null)
            {
                (win_PostAddFriend as Win_PostAddFriend).txt_Number.Text     = "";
                (win_PostAddFriend as Win_PostAddFriend).TB_Age.Text          = "无";
                (win_PostAddFriend as Win_PostAddFriend).TB_NickName.Text = "无";
                (win_PostAddFriend as Win_PostAddFriend).TB_Prod.Text          = "无";
                (win_PostAddFriend as Win_PostAddFriend).TB_Sex.Text           ="无";
            }
        }

        /// <summary>
        ///     获取好友信息后，加载到好友信息列表中
        /// </summary>
        /// <param name="inpackage">回馈要添加到的好友信息包</param>
        public static void View_GetPostFriendInfo(GetPostFriendInfo_ReplyPacket inpackage)
        {
            IMetaData win_PostAddFriend = Globle.popWindowManager.GetMemberByKey("PostAddFriend");
            if (win_PostAddFriend != null)
            {
                (win_PostAddFriend as Win_PostAddFriend).TB_Age.Text          = inpackage.GetValueByKey("AGE");
                (win_PostAddFriend as Win_PostAddFriend).TB_NickName.Text = inpackage.GetValueByKey("NICKNAME");
                (win_PostAddFriend as Win_PostAddFriend).TB_Prod.Text         = inpackage.GetValueByKey("PROD");
                (win_PostAddFriend as Win_PostAddFriend).TB_Sex.Text          = inpackage.GetValueByKey("SEX") == "0"?"男":"女";
                (win_PostAddFriend as Win_PostAddFriend).SP_InputNumber.Visibility = System.Windows.Visibility.Collapsed;
                (win_PostAddFriend as Win_PostAddFriend).btn_OK.Content = "添加";
            }
        }

        private static void ShowNotifyWindow(String NotifyText)
        {
            LoginProcessModel.ChangeState(false, Globle.win_Login);
            Win_Notify WN = new Win_Notify();
            WN.Owner = Globle.win_Login;
            WN.tb_Notify.Text = NotifyText;
            WN.ShowDialog();
        }
    }
}
